/* http://docs.angularjs.org/#!angular.service */

/**
 * App service which is responsible for the main configuration of the app.
 */
angular.service('myAngularApp', function($route, $location, $window) {

  $route.when('signup', {template: 'public/partials/signup.html', controller: SignupCtrl});
  $route.when('login', {template: 'public/partials/login.html', controller: LoginCtrl});
  $route.when('logout', {controller: LogoutCtrl});
  $route.when('search', {template: 'public/partials/search.html', controller: SearchCtrl});
  $route.when("!/artist/:id", {template: 'public/partials/artist.html', controller: ArtistCtrl});
  $route.when("!/release/:id", {template: 'public/partials/release.html', controller: ReleaseCtrl});
  $route.when("!/label/:id", {template: 'public/partials/label.html', controller: LabelCtrl});
  $route.when("search/artist/:page/:query",
      {template: 'public/partials/artist_search.html', controller: ArtistSearchCtrl});
  $route.when("search/label/:page/:query",
      {template: 'public/partials/label_search.html', controller: LabelSearchCtrl});
  $route.when("search/release/:page/:query",
      {template: 'public/partials/release_search.html', controller: ReleaseSearchCtrl});
  $route.when("search/track/:page/:query",
      {template: 'public/partials/track_search.html', controller: TrackSearchCtrl});
  $route.when("my-playlists",
      {template: 'public/partials/my_playlists.html', controller: MyPlaylistsCtrl});
  $route.when("playlist/:id",
      {template: 'public/partials/playlist.html', controller: PlaylistCtrl});
  $route.when("mostliked/:page",
      {template: 'public/partials/mostliked.html', controller: MostLikedCtrl});
  $route.when("mostdisliked/:page",
      {template: 'public/partials/mostdisliked.html', controller: MostDislikedCtrl});
  $route.when("", {template: 'public/partials/index.html', controller: IndexCtrl});


  var self = this;

  $route.onChange(function() {
    if ($location.hash === '') {
//      $location.updateHash('/view1');
//      self.$eval();
    } else {
      $route.current.scope.params = $route.current.params;
//      $window.scrollTo(0,0);
    }
  });

}, {$inject:['$route', '$location', '$window'], $eager: true});

